package com.stormragetech.demo.hbase.spring.dao.hbase;

import lombok.extern.log4j.Log4j2;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.springframework.stereotype.Repository;

import java.io.IOException;

/**
 * description: //TODO
 *
 * @author: Xue Bin
 * @version: 1.0.0-SNAPSHOT
 */
@Log4j2
@Repository
public class HBaseDaoImpl extends HBaseBaseDao implements HBaseDao {

    @Override
    public void create() throws IOException {
        createTable("user", "info");
    }

    @Override
    public void del() throws IOException {
        delTable("user");
    }

    @Override
    public void putUser() throws IOException {
        put("user.1", "name", "tom", "info", "user");
    }

    @Override
    public String getUser() throws IOException {
        Result result = get("user.1", "name", "info", "user");
        return new String(result.getValue(Bytes.toBytes("info"), Bytes.toBytes("name")), "UTF-8");
    }
}
